/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.eng.scc.core.conn.serial;

import java.sql.Date;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 *
 * @author Rafael
 */
public class ProtocolData
{
    private List<FuelValue> fuelValues = new ArrayList<FuelValue>();
    
    private int serial = 0;
    private short carrying;
    
    private double sum;
    
    public class FuelValue
    {
        private List<Short> data = new ArrayList<Short>();
        private Date transmitedDate = null;

        private FuelValue( Date value )
        {
            transmitedDate = value;
        }

        public List<Short> getData()
        {
            return data;
        }

        public void addData( List<Short> data )
        {
            this.data.addAll( data );
        }

        public Date getTransmitedDate()
        {
            return transmitedDate;
        }

        public void setTransmitedDate( Date transmitedDate )
        {
            this.transmitedDate = transmitedDate;
        }
    }

    public void addFuelValue( Short[] value )
    {
        FuelValue f = fuelValues.get( fuelValues.size() - 1 );
        
        if ( f != null )
        {
            f.addData( Arrays.asList( value ) );
        }
    }
    
    public List<FuelValue> getValues()
    {
        return fuelValues;
    }
    
    public void addFuelDate( Date value )
    {
        fuelValues.add( new FuelValue( value ) );
    }
    
    public short getCarrying()
    {
        return carrying;
    }

    public void setCarrying( short carrying )
    {
        this.carrying = carrying;
    }
    
    public double getSum()
    {
        return sum;
    }

    public void setSum( double sum )
    {
        this.sum = sum;
    }
    
    public int getSerial()
    {
        return serial;
    }

    public void setSerial( int serial )
    {
        this.serial = serial;
    }

    @Override
    public String toString()
    {
        return "0x" + Integer.toHexString( serial ).toUpperCase() + " ";
    }
}
